package com.appwoo.txtws.util;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.drawable.Drawable;
import com.appwoo.txtws.bean.AutoSoftInfo;
import com.appwoo.txtws.component.Logger;
import java.util.ArrayList;

public class ShowShortcutUtils
{
  private static final int ICON_COUNT = 4;
  private static final int MARGIN = 2;
  private static final int NUM_COL = 2;
  private static final int PADDING = 1;

  public static Drawable getFolderIcon(Resources paramResources, AutoSoftInfo paramAutoSoftInfo)
  {
    if (paramAutoSoftInfo.getContents().size() == 0)
      return null;
    Bitmap localBitmap1 = BitmapFactory.decodeResource(paramResources, 2130837701);
    int i = localBitmap1.getWidth();
    Bitmap localBitmap2 = Bitmap.createBitmap(i, i, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap2);
    localCanvas.drawBitmap(localBitmap1, 0.0F, 0.0F, null);
    Logger.i("graggrid", "  iconWidth:" + i + " closebmp:" + localBitmap1.getWidth());
    Matrix localMatrix = new Matrix();
    float f1 = -2 + (i - 4) / 2;
    float f2 = f1 / i;
    localMatrix.postScale(f2, f2);
    for (int j = 0; ; j++)
    {
      if (j >= 4);
      while (true)
      {
        FastBitmapDrawable localFastBitmapDrawable = new FastBitmapDrawable(localBitmap2);
        return localFastBitmapDrawable;
        try
        {
          if (j >= paramAutoSoftInfo.getContents().size())
            break;
          float f3 = 2 + 1 * (1 + 2 * (j % 2)) + f1 * (j % 2);
          float f4 = 2 + 1 * (1 + 2 * (j / 2)) + f1 * (j / 2);
          Bitmap localBitmap3 = BitmapUtils.drawableToBitmap(((ShortcutInfo)paramAutoSoftInfo.getContents().get(j)).getDrawable());
          if (localBitmap3.getWidth() < i);
          Bitmap localBitmap4;
          for (Object localObject = Bitmap.createBitmap(localBitmap3, 0, 0, localBitmap3.getWidth(), localBitmap3.getHeight(), localMatrix, true); ; localObject = localBitmap4)
          {
            localCanvas.drawBitmap((Bitmap)localObject, f3, f4, null);
            break;
            localBitmap4 = Bitmap.createBitmap(localBitmap3, 0, 0, i, i, localMatrix, true);
          }
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    }
  }

  // ERROR //
  private java.lang.String saveLogo(Drawable paramDrawable, java.lang.String paramString)
  {
    // Byte code:
    //   0: invokestatic 136	com/appwoo/txtws/component/Global:isSDCard	()Z
    //   3: ifeq +92 -> 95
    //   6: getstatic 140	com/appwoo/txtws/component/Global:IMGPATH	Ljava/lang/String;
    //   9: astore_3
    //   10: new 67	java/lang/StringBuilder
    //   13: dup
    //   14: aload_3
    //   15: invokestatic 146	java/lang/String:valueOf	(Ljava/lang/Object;)Ljava/lang/String;
    //   18: invokespecial 72	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   21: aload_2
    //   22: invokevirtual 81	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   25: invokevirtual 85	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   28: astore 4
    //   30: aload_1
    //   31: checkcast 148	android/graphics/drawable/BitmapDrawable
    //   34: invokevirtual 152	android/graphics/drawable/BitmapDrawable:getBitmap	()Landroid/graphics/Bitmap;
    //   37: astore 5
    //   39: new 154	java/io/ByteArrayOutputStream
    //   42: dup
    //   43: invokespecial 155	java/io/ByteArrayOutputStream:<init>	()V
    //   46: astore 6
    //   48: aload 5
    //   50: getstatic 161	android/graphics/Bitmap$CompressFormat:PNG	Landroid/graphics/Bitmap$CompressFormat;
    //   53: bipush 100
    //   55: aload 6
    //   57: invokevirtual 165	android/graphics/Bitmap:compress	(Landroid/graphics/Bitmap$CompressFormat;ILjava/io/OutputStream;)Z
    //   60: pop
    //   61: aload 6
    //   63: invokevirtual 168	java/io/ByteArrayOutputStream:flush	()V
    //   66: aload 6
    //   68: invokevirtual 171	java/io/ByteArrayOutputStream:close	()V
    //   71: new 173	java/io/FileOutputStream
    //   74: dup
    //   75: aload 4
    //   77: invokespecial 174	java/io/FileOutputStream:<init>	(Ljava/lang/String;)V
    //   80: astore 9
    //   82: aload 9
    //   84: aload 6
    //   86: invokevirtual 178	java/io/ByteArrayOutputStream:toByteArray	()[B
    //   89: invokevirtual 182	java/io/FileOutputStream:write	([B)V
    //   92: aload 4
    //   94: areturn
    //   95: getstatic 185	com/appwoo/txtws/component/Global:IMGPATHMEMORY	Ljava/lang/String;
    //   98: astore_3
    //   99: goto -89 -> 10
    //   102: astore 8
    //   104: aload 8
    //   106: invokevirtual 186	java/io/IOException:printStackTrace	()V
    //   109: goto -38 -> 71
    //   112: astore 10
    //   114: aload 10
    //   116: invokevirtual 186	java/io/IOException:printStackTrace	()V
    //   119: aload 4
    //   121: areturn
    //   122: astore 10
    //   124: goto -10 -> 114
    //
    // Exception table:
    //   from	to	target	type
    //   61	71	102	java/io/IOException
    //   71	82	112	java/io/IOException
    //   82	92	122	java/io/IOException
  }

  public static void updateFolderIcon(Resources paramResources, AutoSoftInfo paramAutoSoftInfo)
  {
    if (paramAutoSoftInfo.getContents().size() == 0)
      return;
    Bitmap localBitmap1 = BitmapFactory.decodeResource(paramResources, 2130837701);
    int i = localBitmap1.getWidth();
    Bitmap localBitmap2 = Bitmap.createBitmap(i, i, Bitmap.Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap2);
    localCanvas.drawBitmap(localBitmap1, 0.0F, 0.0F, null);
    Logger.i("graggrid", "  iconWidth:" + i + " closebmp:" + localBitmap1.getWidth());
    Matrix localMatrix = new Matrix();
    float f1 = -2 + (i - 4) / 2;
    float f2 = f1 / i;
    localMatrix.postScale(f2, f2);
    for (int j = 0; ; j++)
    {
      if (j >= 4);
      while (true)
      {
        FastBitmapDrawable localFastBitmapDrawable = new FastBitmapDrawable(localBitmap2);
        paramAutoSoftInfo.setDeskicon(localFastBitmapDrawable);
        return;
        try
        {
          if (j >= paramAutoSoftInfo.getContents().size())
            break;
          float f3 = 2 + 1 * (1 + 2 * (j % 2)) + f1 * (j % 2);
          float f4 = 2 + 1 * (1 + 2 * (j / 2)) + f1 * (j / 2);
          Bitmap localBitmap3 = BitmapUtils.drawableToBitmap(((ShortcutInfo)paramAutoSoftInfo.getContents().get(j)).getDrawable());
          if (localBitmap3.getWidth() < i);
          Bitmap localBitmap4;
          for (Object localObject = Bitmap.createBitmap(localBitmap3, 0, 0, localBitmap3.getWidth(), localBitmap3.getHeight(), localMatrix, true); ; localObject = localBitmap4)
          {
            localCanvas.drawBitmap((Bitmap)localObject, f3, f4, null);
            break;
            localBitmap4 = Bitmap.createBitmap(localBitmap3, 0, 0, i, i, localMatrix, true);
          }
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.util.ShowShortcutUtils
 * JD-Core Version:    0.6.2
 */